# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=portablexdr
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_base_ver=4.9.2
pkgver=4.9.2.r27.94fb83c
pkgrel=3
pkgdesc="PortableXDR / RPC Library (mingw-w64)"
arch=(any)
url="https://github.com/Alexpux/portablexdr"
license=('LGPL2')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-libtool" "git")
options=('staticlibs' 'strip')
source=(${_realname}::git+https://github.com/Alexpux/portablexdr.git#branch=Branch_4.9.1)
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "%s.r%s.%s" ${_base_ver} "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${_realname}"
  autoreconf -fiv
}

build() {
  [[ -d "$srcdir/build-${MINGW_CHOST}" ]] && rm -rf "$srcdir/build-${MINGW_CHOST}"
  mkdir "$srcdir/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --enable-shared \
      --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
